package com.hlw.hr_man.serviceImpl;

import com.hlw.hr_man.dao.AddressDao;
import com.hlw.hr_man.daoImpl.AddressDaoImpl;
import com.hlw.hr_man.service.AddressService;
import com.sun.org.apache.bcel.internal.generic.NEW;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

/**
 * @author Eumenides
 * 2016年9月12日下午4:06:49
 */
public class AddressServiceImpl implements AddressService{
	JSONObject adrs = new JSONObject();
	JSONArray adrsarray = new JSONArray();
	AddressDao adrdao = new AddressDaoImpl();
	
	@Override
	public JSONObject findAllAddress(int start, int pageSize) {
		// TODO Auto-generated method stub
		adrs.put("total", adrdao.getAddressCount());
		adrs.put("rows", adrdao.getAllAddress(start, pageSize));
		return adrs;
	}

	@Override
	public JSONObject findAddressByValue(String value, int start, int pageSize) {
		// TODO Auto-generated method stub
		adrs.put("total", adrdao.getAddressCount(value));
		adrs.put("rows", adrdao.getSeacherAddress(value, start, pageSize));
		return adrs;
	}
	
	//得到所有的部门名称
	@Override
	public JSONArray findAllDept() {
		// TODO Auto-generated method stub
		
		return adrdao.getAllDept();
	}
	
	//通过性别找员工通讯录
	@Override
	public JSONObject findAddressBySex(String sex, int start, int pageSize) {
		// TODO Auto-generated method stub
		adrs.put("total", adrdao.getCountBySex(sex));
		adrs.put("rows", adrdao.getSexAddress(sex, start, pageSize));
		System.out.println(adrs);
		return adrs;
	}
	
	//通过部门id查找
	@Override
	public JSONObject findAddressByDeptId(int deptid, int start, int pageSize) {
		// TODO Auto-generated method stub
		adrs.put("total", adrdao.getCountByDept(deptid));
		adrs.put("rows", adrdao.getAddressByDeptId(deptid, start, pageSize));
		return adrs;
	}


}
